//
//  ZCXUserPerDetialViewController.m
//  LoveOfPet
//
//  Created by dllo on 15/11/17.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "ZCXUserPerDetialViewController.h"
#import "ZCXUserPetDetialTableViewCell.h"
#import "ZCXUserPerFirstTableViewCell.h"
#import <SVProgressHUD.h>
#define HEIGHT  [[UIScreen mainScreen]bounds].size.height / 667
#define WIDTH   [[UIScreen mainScreen]bounds].size.width / 375
@interface ZCXUserPerDetialViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *nameArray;
@property (nonatomic, retain) NSArray *valuesArray;
@property (nonatomic, retain) NSArray *sectionArray;
@end

@implementation ZCXUserPerDetialViewController
- (void)dealloc{
    [_userDetial release];
    [_tableView release];
    [_nameArray release];
    [_valuesArray release];
    [_sectionArray release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
   self.title = @"个人资料";
     self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.nameArray = @[@"性别:", @"年龄:", @"出生日期: "];
    self.sectionArray = @[@"", @"个性签名", @"更多资料"];
    self.valuesArray = @[_userDetial.gender, _userDetial.age, _userDetial.birthday];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64 * HEIGHT) style:UITableViewStyleGrouped];
    _tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"geren.jpg"]];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    //注册Cell
    [_tableView registerClass:[ZCXUserPetDetialTableViewCell class] forCellReuseIdentifier:@"zcxuserpetdetialtableviewcell"];
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"zcxtableviewcell"];
    
    [_tableView registerClass: [ZCXUserPerFirstTableViewCell class]forCellReuseIdentifier:@"zcxuserperfirsttableviewcell"];
    _tableView.separatorStyle = 0;
    
    [self.view addSubview:_tableView];
    [_tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0 || section == 1) {
        return 1;
    }else {
        return 3;
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        ZCXUserPerFirstTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"zcxuserperfirsttableviewcell" forIndexPath:indexPath];
        cell.selectionStyle = 0;
        cell.userdetial = _userDetial;
//        cell.backgroundColor = [UIColor grayColor];
//        cell.alpha = 0.2;
        cell.backgroundColor = [UIColor clearColor];
        return cell;
    }else if (indexPath.section == 1) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"zcxtableviewcell" forIndexPath:indexPath];
        UILabel *label = [[UILabel alloc]init];
        label.frame = CGRectMake(5 * WIDTH, 5 * HEIGHT, cell.frame.size.width - 10 * WIDTH, cell.frame.size.height - 10 * HEIGHT);
        label.text = [NSString stringWithFormat:@"   %@",_userDetial.Description];
        label.font = [UIFont systemFontOfSize:13];
        label.lineBreakMode = NSLineBreakByCharWrapping;
        label.numberOfLines = 0;
        [cell addSubview:label];
         cell.selectionStyle = 0;
        cell.backgroundColor = [UIColor clearColor];
        return cell;
    }else{
    ZCXUserPetDetialTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"zcxuserpetdetialtableviewcell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.section == 2) {
        cell.name = self.nameArray[indexPath.row];
        cell.values =[NSString stringWithFormat:@"%@", self.valuesArray[indexPath.row]];
    }
        cell.backgroundColor = [UIColor clearColor];
    return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 100;
    }else if (indexPath.section == 1) {
        return 60;
    }else{
        return 50;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UILabel *label = [[UILabel alloc]init];
    label.text = [NSString stringWithFormat:@"   %@", self.sectionArray[section]];
    return label;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
- (void)viewWillDisappear:(BOOL)animated{
    [SVProgressHUD dismiss];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
